package com.newtouch.bxzs.business.product.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newtouch.bxzs.business.product.model.InsuranceBO;
import com.newtouch.bxzs.common.base.model.Additional;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 附加险的Mapper类，必须继承BaseMapper
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/13 13:42</td>
 * <td>lanwei</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author lanwei
 * @version 1.0.0
 * @since 1.0.0
 */
@Mapper
public interface AdditionalMapper extends BaseMapper<Additional> {

    /**
     * 根据建议书id查看附加险集合
     *
     * @param recommendationId 建议书id
     * @return InsuranceBO集合
     */
    @Select("SELECT\n" + "\ta.ADDITIONAL_INSURANCE_NAME as productName,\n" + "\tb.POLICY_AMOUNT as policyAmount,\n"
            + "\tb.POLICY_PREMIUM as policyPremium,b.ADDITIONAL_INSURANCE_CODE as productCode\n" + "FROM\n" + "\tASSISTANT_ADDITIONAL AS a LEFT\n"
            + "\tJOIN ASSISTANT_RECOMMENDATION_INSURANCE_MAP AS b ON a.ADDITIONAL_INSURANCE_CODE = b.ADDITIONAL_INSURANCE_CODE \n"
            + "WHERE\n" + "\tb.RECOMMENDATION_ID = #{recommendationId}")
    List<InsuranceBO> getInsuranceBOList(@Param("recommendationId") String recommendationId);

}
